package com.sun.mvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class ViewController {

    @RequestMapping(value = {"/testThymeleafView"})
    public String testThymeleafView(HttpServletRequest request){
        //request.setAttribute("haha", "hehe");
        return "success";
    }

    @RequestMapping(value = {"/testForward"})
    public String testForward(HttpServletRequest request){
        request.setAttribute("haha", "xixi");
        return "forward:/testThymeleafView";
    }

    @RequestMapping(value = {"/testRedirect"})
    public String testRedirect(HttpServletRequest request){
        request.setAttribute("haha", "xixi");
        return "redirect:http://www.baidu.com";
    }

    @RequestMapping(value = {"/testRedirect1"})
    public String testRedirect1(HttpServletRequest request){
        request.setAttribute("haha", "xixi");
        return "redirect:/testThymeleafView";
    }
}
